package com.dss.enums;


import java.util.HashMap;
import java.util.Map;

public enum RescueTechnique {
	FIREDISASTER(1, "火灾"),
	GASEXPLOSION(2, "瓦斯爆炸"),
	COLLAPSE(3, "塌方"),
	POISONING(4, "中毒");
	
	private int value;
	private String title;

	RescueTechnique(int value, String title) {
		this.value = value;
		this.title = title;
	}

    /**
     * 获取枚举值
     * @return 返回枚举值
     */
	public int value() {
		return this.value;
	}

    /**
     * 获取枚举标题
     * @return 返回枚举的标题
     */
	public String title() {
		return this.title;
	}

	private static Map<String, RescueTechnique> titlefinder;
	static {
		titlefinder = new HashMap<String, RescueTechnique>();
		for (RescueTechnique item : RescueTechnique.values())
			titlefinder.put(item.title(), item);

	}

	private static Map<Integer, RescueTechnique> valuefinder;
	static {
		valuefinder = new HashMap<Integer, RescueTechnique>();
		for (RescueTechnique item : RescueTechnique.values())
			valuefinder.put(new Integer(item.value()), item);

	}

	/**
	 * 按照枚举值查找枚举
	 * 
	 * @param value
	 *            数据类型值对象
	 * @return 返回枚举值对象
	 */
	public static RescueTechnique valueOf(int type) {
		return valuefinder.get(new Integer(type));
	}
	
	/**
	 * 按照枚举标题查找枚举值
	 * 
	 * @param value
	 *            数据类型值对象
	 * @return 返回枚举值对象
	 */
	public static RescueTechnique titleOf(String title) {
		return titlefinder.get(title);
	}
	
	public static RescueTechnique[] getMembers() {
		return new RescueTechnique[] {FIREDISASTER, GASEXPLOSION, COLLAPSE, POISONING};
	}
}
